package logic

import (
	"context"
	"work/workrpc/workrpc"

	"work/api/internal/svc"
	"work/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type ContentAddLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewContentAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ContentAddLogic {
	return &ContentAddLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *ContentAddLogic) ContentAdd(req *types.ContentAddRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	add, err := l.svcCtx.WorkRpc.ContentAdd(l.ctx, &workrpc.ContentAddRequest{
		UserId:  int64(req.UserId),
		StoryId: int64(req.StoryId),
		Comment: req.Comment,
	})
	if err != nil {
		return &types.Response{
			Message: "添加失败",
			Code:    500,
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Message: "添加成功",
		Code:    200,
		Data:    add,
	}, nil
}
